﻿using _1_Interfaces.Interfaces.Cjw;
using _1_Interfaces.Models.Dtos.Cjw;
using _1_Interfaces.Models.Tables.Cjw;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace _3_Controllers.Controllers.Cjw
{
    /// <summary>
    /// 通知栏表服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CjwNoticeListController : ControllerBase
    {
        private INoticeListService _noticeListService;
        public CjwNoticeListController(INoticeListService noticeListService)
        {
            _noticeListService = noticeListService;
        }

        /// <summary>
        /// 获取通知栏列表
        /// </summary>
        /// <param name="pageIndex">第几页</param>
        /// <param name="pageSize">一页几条</param>
        /// <returns></returns>
        [HttpGet]
        public NoticeListDto GetNoticeList(int pageIndex, int pageSize)
        {
            return _noticeListService.GetNoticeList(pageIndex, pageSize);
        }

        /// <summary>
        /// 新增通知栏内容
        /// </summary>
        /// <param name="noticeList">通知栏表实体，id不用传，后端赋值</param>
        /// <returns></returns>
        [HttpPost]
        public bool AddNotice(NoticeList noticeList)
        {
            return _noticeListService.AddNotice(noticeList);
        }

        /// <summary>
        /// 编辑通知栏内容
        /// </summary>
        /// <param name="noticeList">通知栏表实体</param>
        /// <returns></returns>
        [HttpPost]
        public bool EditNotice(NoticeList noticeList)
        {
            return _noticeListService.EditNotice(noticeList);
        }

        /// <summary>
        /// 删除通知栏内容 
        /// </summary>
        /// <param name="noticeId ">通知信息id</param>
        /// <returns></returns>
        [HttpGet]
        public bool DelNotice(int noticeId)
        {
            return _noticeListService.DelNotice(noticeId);
        }

        /// <summary>
        /// 获取通知栏
        /// </summary>
        /// <param name="noticeId">通知栏id</param>
        /// <returns></returns>
        [HttpGet]
        public NoticeList GetNoticeByNoticeId(int noticeId)
        {
            return _noticeListService.GetNoticeByNoticeId(noticeId);
        }
    }
}
